package domain;

import javax.persistence.Access;

import javax.persistence.AccessType;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.OneToOne;
import javax.persistence.Transient;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.SafeHtml;
import org.hibernate.validator.constraints.SafeHtml.WhiteListType;

import security.UserAccount;

@Entity
@Access(AccessType.PROPERTY)
public abstract class Actor extends DomainEntity {
	
	// Constructors
	
	public Actor(){
		super();
	}
	
	// Atributes
	
	private String name;
	private String surnames;
	private String email;
	
	@NotNull
	@NotBlank
	@SafeHtml( whitelistType = WhiteListType.NONE )
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	@NotNull
	@NotBlank
	@SafeHtml( whitelistType = WhiteListType.NONE )
	public String getSurnames() {
		return surnames;
	}
	
	public void setSurnames(String surnames) {
		this.surnames = surnames;
	}
	
	@NotNull
	@NotBlank
	@Email
	public String getEmail() {
		return email;
	}
	
	public void setEmail(String email) {
		this.email = email;
	}
	
	// Relationships
	
	private UserAccount userAccount;
	
	@NotNull
	@Valid
	@OneToOne(cascade = CascadeType.ALL, optional = false)
	public UserAccount getUserAccount() {
		return userAccount;
	}

	public void setUserAccount(UserAccount userAccount) {
		this.userAccount = userAccount;
	}
	
	//Ancillary methods
	
	@Transient
	public String nombreCompleto(){
		return getName() + " " + getSurnames();
	}
	
	

}
